package com.his.controller;

import com.his.common.Const;
import com.his.common.RoleId;
import com.his.common.Rsp;
import com.his.service.HisUserService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

/**
 * (HisUser)表控制层
 *
 * @author makejava
 * @since 2020-10-23 18:09:50
 */
@RestController
@RequestMapping("hisUser")
@Validated
public class HisUserController {
    /**
     * 服务对象
     */
    @Resource
    private HisUserService hisUserService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Rsp selectOne(Integer id) {
        return Rsp.success(this.hisUserService.queryById(id));
    }

    /**
     * 查医生列表
     * @return
     */
    @PostMapping("selectDoctorList")
    public Rsp selectDoctorList(){
        return this.hisUserService.selectDoctorList();
    }



    @GetMapping("getNurseByDepId")
    public Rsp getNurseByDepId(@RequestHeader(Const.TOKEN) String token, String depId){
        return hisUserService.getHisUserByDepIdAndRoleId(depId, RoleId.NURSE);
    }

    /**
     * 查询某个科室下的医生信息
     * @param token 前端的token
     * @param depId 科室id
     * @return 医生信息
     */
    @GetMapping("getDoctorByDepId")
    public Rsp getDoctorByDepId(@RequestHeader(Const.TOKEN) String token, @NotBlank(message = "科室id不能为空") String depId){
        return hisUserService.getHisUserByDepIdAndRoleId(depId, RoleId.DOCTOR);
    }
}
